package com.ctw.mall.Interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 *配置拦截器
 */
@Configuration//不加这个注解该类不生效
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserLoginInterceptor())     //将自己写的拦截器注册上，并添加哪些路径拦截哪些不拦截
                .addPathPatterns("/**")
                .excludePathPatterns("/error","/user/register","/user/login","/categories","/products","/products/*");
    }
}
//在请求"/carts"时，产生错误,springboot内部将错误重定向,跳转到/error,但并未拦截，还是去校验是否登录
//异常处理MethodArgumentNotValidException